//路由跳转 案例
import 'package:flutter/material.dart';
import '../search.dart';
import '../form.dart';
import '../tabs/news.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          ElevatedButton(
            onPressed: () {
              //跳转路由
              Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) {
                    return SearchPage();
                  },
                ),
              );
            },
            child: Text('跳转搜索页面'),
          ),
          SizedBox(height: 20),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) {
                    return FormPage();
                  },
                ),
              );
            },
            child: Text('跳转表单页面'),
          ),
          SizedBox(height: 20),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) {
                    return Newspage(title: '传递的参数新闻',aid: 60,);
                  },
                ),
              );
            },
            child: Text('跳转新闻页面'),
          ),
        ],
      ),
    );
  }
}
